def hannoi(n, A, B, C):
    if n > 0:
        hannoi(n - 1, A, C, B)  # A为所在柱子，B为经过柱子，C为到达柱子
        print('%s->%s' % (A, C))
        hannoi(n - 1, B, A, C)


# 移动次数: h(n)=2h(n-1)+1
hannoi(3, 'A', 'B', 'C')
